(function() {
	$J('body').on('click', 'a[name="updatestatus"]', function() {
		updateStatus(this);
	});
	
	var updateStatus = function(obj) {
		var id = $J(obj).data('content');
		var status = $J(obj).data('status') == 2 ? 1 : 2;
		$J.ajax({
			type : 'PUT',
			url : window.baseUrl + "/user/user/" + id + "/freeze" + "?status=" + status,
			dataType : 'json',
			async : true,
			cache : false,
			success : function(data) {
				if(data.status == false) {
					if(data.msg) {
						alert(data.msg);
					}
					return;
				} 
				location.reload();
			},
			error : function(data) {
				alert(data.msg);
			}
		});
	}

})();
